package org.ruixue.controller;

import org.ruixue.response.BaseResponse;
import org.ruixue.util.DateUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.text.ParseException;

@RestController
@EnableAutoConfiguration
@RequestMapping("/test")
public class TestController {

    private static final Logger log = LoggerFactory.getLogger(TestController.class);
    
    /**
     * http://localhost:40005/microservice-yiyouyayin/test/helloCainiao
     *
     * @return
     */
    @RequestMapping(value = "/helloCainiao", method = RequestMethod.GET)
    @ResponseBody
    private ResponseEntity<BaseResponse> helloCainiao() {

        log.info("helloCainiao =====================================");

        BaseResponse response = new BaseResponse();
        try {
            response.setMsg(DateUtil.getCurrentDateStr());
        } catch (ParseException e) {
            response.setMsg(e.getMessage());
            response.setSuccess("false");
            e.printStackTrace();
        }
        return new ResponseEntity<BaseResponse>(response, HttpStatus.OK);
    }
}
